jQuery fn.extend ({bla: function(){}} vs. jQuery.fn.bla

Posted by tixrus on Stack Overflow See other posts from Stack Overflow or by tixrus
Published on 2010-04-09T18:37:57Z Indexed on 2010/04/09 18:43 UTC
Read the original article Hit count: 548

OK I think I get http://stackoverflow.com/questions/1991126/difference-jquery-extend-and-jquery-fn-extend

in that the general extend can extend any object, and that fn.extend is for plugin functions that can be invoked straight off the jquery object with some internal jquery voodoo.

So it appears one would invoke them differently. If you use general extend to extend object obj by adding function y, then the method would attach to that object, obj.y() but if you use fn.extend then they are attach straight to the jquery object $.y().... Have I got that correct yes or no and if no what do I have wrong in my understanding?

Now MY question:

The book I am reading advocates using jQuery.fn.extend ({a: function(){}, b: function(){}}); syntax but in the docs it says

jQuery.fn.a (function(){}); and I guess if you wanted b as well it would be jQuery.fn.b (function(){});

Are these functionally and performance-wise equivalent and if not what is the difference?

Thank you very much. I am digging jQuery!

© Stack Overflow or respective owner

Related posts about jquery-plugins

Related posts about extend